From 37334931744c84dde599752fca94b2f43445bc0b Mon Sep 17 00:00:00 2001 From: Gleb Kozyrev Date: Tue, 13 Oct 2015 03:31:57 +0300 Subject: [PATCH] Clarify the default `cargo run` error message on a non-zero exit code The behavior is the same in the default and verbose modes now: - the default mode will not suggest re-running with `--verbose` - the verbose mode will not print the binary name. --- src/bin/run.rs | 7 +++++-- tests/test_cargo_run.rs | 8 ++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/bin/run.rs b/src/bin/run.rs index 2483dcc8d..838ac4655 100644 --- a/src/bin/run.rs +++ b/src/bin/run.rs @@ -1,5 +1,5 @@ use cargo::ops; -use cargo::util::{CliResult, CliError, Config}; +use cargo::util::{CliResult, CliError, Config, human}; use cargo::util::important_paths::{find_root_manifest_for_cwd}; #[derive(RustcDecodable)] @@ -92,7 +92,10 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { None => Ok(None), Some(err) => { Err(match err.exit.as_ref().and_then(|e| e.code()) { - Some(i) => CliError::from_error(err, i), + Some(code) => { + let desc = format!("Process finished with exit status {}", code); + CliError::from_boxed(human(desc), code) + } None => CliError::from_error(err, 101), }) } diff --git a/tests/test_cargo_run.rs b/tests/test_cargo_run.rs index 3ad49c418..f2dab301c 100644 --- a/tests/test_cargo_run.rs +++ b/tests/test_cargo_run.rs @@ -102,7 +102,11 @@ test!(exit_code { "#); assert_that(p.cargo_process("run"), - execs().with_status(2)); + execs().with_status(2) + .with_stderr(&format!("\ +Process finished with exit status 2 +", + ))); }); test!(exit_code_verbose { @@ -120,7 +124,7 @@ test!(exit_code_verbose { assert_that(p.cargo_process("run").arg("-v"), execs().with_status(2) .with_stderr(&format!("\ -Process didn't exit successfully: `target[..]foo` (exit code: 2) +Process finished with exit status 2 ", ))); }); -- 2.30.2